package Array;

public class item303 {
}
class NumArray {
    int  [] leftToRight;
    int len;
    public NumArray(int[] nums) {
         leftToRight  = new int[nums.length];

         len = nums.length;
         leftToRight[0] = nums[0];

        for (int i = 1; i < nums.length; i++) {
            leftToRight[i] = leftToRight[i-1]+nums[i];
        }

    }

    public int sumRange(int left, int right) {
//        return leftToRight[right] -leftToRight[left-1];
        if(left==0)
        {
            return  leftToRight[right];
        }else
        {
            return  leftToRight[right]-leftToRight[left-1];
        }

    }
}